package com.bw.flinkstreaming.source1.job2;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class NotParallelSourceTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //加载自定义的数据源
        DataStreamSource<Long> dataStreamSource = env.addSource(new NotParallelSource()).setParallelism(2);
        SingleOutputStreamOperator<Long> result = dataStreamSource.filter(new FilterFunction<Long>() {
            @Override
            public boolean filter(Long value) throws Exception {
                System.out.println("接受到的数据： "+value);
                return value % 2 ==0;
            }
        });

        result.print().setParallelism(1);
        env.execute("NotParallelSourceTest");


    }
}
